<?php
class User extends Model {
	
	public function login($data){
		$result = $this->dbo->query("SELECT customer_id,name,email FROM customer WHERE name='".$this->dbo->escape($data['username'])."' AND password='".md5($this->dbo->escape($data['password']))."'");
		return $result->row;
	}
	
	public function getUserById($customer_id) {
		$result = $this->dbo->query("SELECT * FROM customer WHERE customer_id='".(int)$customer_id."'");
		return $result->row;
	}
	public function countUser() {
		$result = $this->dbo->query("SELECT count(*) as total FROM customer");
		return $result->row['total'];
	}
	public function updateLoginStatics($customer_id,$time) {
		return $this->dbo->query("UPDATE customer SET login_time='".$time."',login_num = login_num + 1 WHERE customer_id='".(int)$customer_id."'");
	}
}
?>